<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        // 1.确定事件 - 页面加载成功事件
        /*onload = function () {
            // 设置单次执行定时器
            setTimeout(jump,5000);
        }*/
        // 2.编写调用的函数
        /*function jump() {
            location.href = "http://www.itheima.com";
        }*/
        //------------------------------
        //1.页面加载成功后,设置周期执行定时器,每个1秒调用指定函数
        let interId;
        onload = function () {
            // 设置单次执行定时器
            interId = setInterval(changeTime,1000);
        }
        let time = 5;
        //2.编写changeTime函数
        function changeTime() {
            time--;
            let spObj = document.getElementById("spId");
            spObj.innerText = time;
            if(time==0){
                //清除周期执行定时器
                clearInterval(interId);
                // 页面跳转
                location.href = "http://www.itheima.com";
            }
        }

    </script>
</head>
<body>
    <h1>支付成功,<span id="spId">5</span>秒后跳转到黑马官网</h1>
</body>
</html>